/**
 * 
 */

/**
 * @author Ashley
 *
 */
public class DivOp extends ArithmeticOp
{
	public DivOp() {
		super("/");
	}
	
	@Override
	public STO calculate(ConstSTO left, ConstSTO right) {
		STO sto;

		if(right.getFloatValue() == 0.0) {
			sto = new ErrorSTO("error8_Arithmetic");
		}
		else if(left.getType().isInt() && right.getType().isInt()) {
			sto = new ConstSTO((left.getName() + "/" + right.getName()), new IntType(), 
				  Integer.toString(left.getIntValue() / right.getIntValue()));
		}
		else {
			sto = new ConstSTO((left.getName() + "/" + right.getName()), new FloatType(), 
					  Double.toString(left.getFloatValue() / right.getFloatValue()));
		}
		return sto;
	}
	
	@Override
	public boolean isDivOp() { 
		return true; 
	}
}